{% extends 'layout.html' %}

{% block head %}
<link rel="stylesheet" href="/static/blog/css/dashboard/post.css" type="text/css">
<link rel="stylesheet" href="/static/blog/css/common/simplemde.min.css" type="text/css">
<script src="/blog/static/js/common/simplemde.min.js" type="text/javascript"></script>
{% endblock %}

{% block foot %}
<script src="/blog/static/js/dashboard/post_edit.js" type="text/javascript"></script>
{% endblock %}

{% block content %}
	{% include 'bread.html'%} 
	<div class="view-content">
	<div class="view-content-container">
		<form id="contentForm" class="form-horizontal" method="POST" action="/dashboard/post/aj_edit">
		  <div class="form-group">
		    <label for="inputTitle" class="col-sm-1 control-label"><i>*</i>标题</label>
		    <div class="col-sm-10">
		      <input value="{{post.title}}" type="text" class="form-control" name="title" id="inputTitle" placeholder="文章标题" required>
		    </div>
		  </div>
		  <div class="form-group">
		    <label for="inputId" class="col-sm-1 control-label"><i>*</i>ID</label>
		    <div class="col-sm-10">
		      <input value="{{post.id}}" type="text" class="form-control" name="id" id="inputId" placeholder="文章ID，仅限英文，数字，中划线，下划线" required {% if post.id %}readonly=true{% endif %}>
		    </div>
		  </div>
		  <div class="form-group">
		    <label for="inputId" class="col-sm-1 control-label"><i>*</i>作者</label>
		    <div class="col-sm-10">
		    	{% if userInfo.isAdmin %}
		    		<select class="form-control" name="author" required>
		    		{% for user in siteInfo.users%}
			    			<option value="{{user.id}}" {% if !post.author && userInfo.id == user.id || post.author && post.author == user.id %}selected="true"{% endif %}>{{ user.name }}</option>
		    		{% endfor %}
		    		</select>
		    	{% else %}
		      		<input type="text" class="form-control" name="author" id="inputId" readonly=true value="{{post.author || userInfo.id}}" required>
		    	{% endif %}
		    </div>
		  </div>
		  <div class="form-group">
		    <label for="inputId" class="col-sm-1 control-label"><i>*</i>分类</label>
		    <div class="col-sm-10">
		    	<select class="form-control" name="category" value="{{ post.category }}" required>
		    		{% for cate in siteInfo.cates%}
		    			<option value="{{cate.id}}" {% if post.category == cate.id%}selected{% endif %}>{{ cate.name }}</option>
		    		{% endfor%}
				</select>
		    </div>
		  </div>
		  <div class="form-group">
		    <label for="inputImage" class="col-sm-1 control-label">图片</label>
		    <div class="col-sm-10">
		      <input value="{{ post.image }}" type="text" class="form-control" name="image" id="inputImage" placeholder="文章主题图片，可不填">
		    </div>
		  </div>
		  <div class="form-group">
		    <label for="inputFrom" class="col-sm-1 control-label">来源</label>
		    <div class="col-sm-10">
		      <input value="{{ post.from }}" type="text" class="form-control" name="from" id="inputFrom" placeholder="文章来源，可不填">
		    </div>
		  </div>
		  <div class="form-group">
		    <label for="inputContent" class="col-sm-1 control-label"><i>*</i>内容</label>
		    <div class="col-sm-10">
		      <textarea type="image" class="form-control" name="content" id="inputContent" placeholder="文章内容">{{ post.content }}</textarea>
		    </div>
		  </div>
		  <div class="form-group">
		    <div class="col-sm-offset-1 col-sm-10">
		      <input type="hidden" name="is_new" value="{{ isNew }}">
		      <button type="submit" class="btn btn-default">提交</button>
		    </div>
		  </div>
		</form>
	</div>
	</div>
{% endblock %}
